package com.hzz.dao.user;

import com.hzz.framework.dao.IBaseDao;
import com.hzz.framework.entity.IEntity;
import org.apache.ibatis.annotations.*;

/**
 * <p>组织架构 数据库处理接口类。
 */
@Mapper
public interface IOrgInfoDao extends IBaseDao {

    /**
      * 判断是否存在
      */
    @Override
    @Select("select IFNULL(count(0),0) as count from org_info where  id = #{id} ")
    int isDataExist(IEntity entity) throws Exception;

    /**
     * 逻辑删除
     */
    @Override
    @Update("update org_info set version=version+1, date_updated=now(), del_flag=1 where  id = #{id} ")
    int deleteById(IEntity entity) throws Exception;


    /**
     * 根据主键 物理删除
     */
    @Override
    @Delete("delete from org_info where  id = #{id} ")
    int deleteByPrimaryKey(IEntity entity) throws Exception;

    @Select("select findOrgAllChildIsList(#{id}) ")
    String findOrgAllChildIsList(IEntity entity) throws Exception;

    /**
     * 判断是否使用
     */
    @Select("select IFNULL(count(0),0) as count from user where org_id in (${orgIds}) ")
    int isUserOrgExist(@Param("orgIds") String orgIds) throws Exception;

    /**
     * 根据主键 物理删除
     */
    @Delete("delete from org_info where id in (${orgIds}) ")
    int deleteAllChildIs(@Param("orgIds") String orgIds) throws Exception;
}